package main

import "fmt"

type Truck string

func (t Truck) Accele() {
	fmt.Println("Speeding up", t)
}

func (t Truck) Brake() {
	fmt.Println("Stopping", t)
}

func (t Truck) Steer(dire string) {
	fmt.Println("Turning", dire)
}

func (t Truck) LoadCargo(cargo string) {
	fmt.Println("Loading", cargo)
}

type Truck2 string

func (t Truck2) Accele() {
	fmt.Println("Speeding up", t)
}

func (t Truck2) Brake() {
	fmt.Println("Stopping", t)
}

func (t Truck2) Steer(dire string) {
	fmt.Println("Turning", dire)
}

type Vehicle interface {
	Accele()
	Brake()
	Steer(string)
}

func TryVehicle(vehicle Vehicle) {
	vehicle.Brake()
	vehicle.Steer("left")
	vehicle.Steer("right")
	truk, ok := vehicle.(Truck)
	if ok {
		truk.LoadCargo("test cargo")
	}
}

func main() {
	TryVehicle(Truck("hujianli aaa"))
	fmt.Println()
	TryVehicle(Truck2("hujianli aaa"))
}
